package leetcodehot100;

import java.util.ArrayList;
import java.util.List;



// * Definition for a binary tree node.
class TreeNode {
    int val;
    TreeNode left;
    TreeNode right;
    TreeNode() {}
    TreeNode(int val) { this.val = val; }
    TreeNode(int val, TreeNode left, TreeNode right) {
       this.val = val;
       this.left = left;
       this.right = right;
    }
 }


public class _94二叉树的中序遍历 {
    public List<Integer> inorderTraversal(TreeNode root) {
        List<Integer> res = new ArrayList<>();
        midOrder(root,res);
        return res;
    }

    void midOrder(TreeNode root,List res){
        if(root==null)
            return;
        midOrder(root.left,res);
        res.add(root.val);
        midOrder(root.right,res);
    }
}
